//
//  SEProfileRecordCvCell.swift
//  SmartEyeForPatient
//
//  Created by qdsg on 2021/4/13.
//

import UIKit

enum SEProfileRecordCvCellType {
    case login
    case add
    case info
}

class SEProfileRecordCvCell: UICollectionViewCell {

    static let className = "SEProfileRecordCvCell"
    static let reuseId = className

    @IBOutlet weak var patientInfoView: SEPatientInfoView! {
        didSet {
            patientInfoView.hideEditButton = true
        }
    }
    @IBOutlet weak var addFileBtn: UIButton!
    @IBOutlet weak var loginBtn: UIButton!

    @IBAction func addFileBtnAction(_ sender: UIButton) {

    }
    @IBAction func loginBtnAction(_ sender: Any) {
    }

    var cellType: SEProfileRecordCvCellType = .login {
        didSet {
            switch cellType {
            case .add:
                patientInfoView.isHidden = true
                loginBtn.isHidden = true
                addFileBtn.isHidden = false
            case .info:
                patientInfoView.isHidden = false
                loginBtn.isHidden = true
                addFileBtn.isHidden = true
            case .login:
                patientInfoView.isHidden = true
                loginBtn.isHidden = false
                addFileBtn.isHidden = true
            }
        }
    }

    override func awakeFromNib() {
        super.awakeFromNib()
        setUI()
    }

    func updateCell(_ viewModel: SEPatientDetailViewModel?, _ type: SEProfileRecordCvCellType) {
        self.cellType = type
        guard let vm = viewModel else { return }
        patientInfoView.updateView(vm)
        contentView.layer.borderColor = vm.borderColor
    }

    private func setUI() {
        contentView.backgroundColor = Asset.border.color
        contentView.setLayerCorners(rect: bounds, radius: 14, corners: [.topLeft, .topRight])
        contentView.layer.borderWidth = 1
        contentView.layer.borderColor = Asset.background.color.cgColor
        contentView.layer.masksToBounds = true
    }

}
